<template>
  <div class="">
    <el-tabs v-model="activityName" type="border-card" @tab-click="tabChange">
      <el-tab-pane name="/reverseSettlement" label="反结原因">
        <div class="page-content">
          <router-view v-if="selectMaterials()"></router-view>
        </div>
      </el-tab-pane>
      <el-tab-pane name="/retreatVegetable" label="退菜原因">
        <div class="page-content">
          <router-view v-if="selectCategorys()"></router-view>
        </div>
      </el-tab-pane>
      <el-tab-pane name="/withoutCharge" label="免单原因">
        <div class="page-content">
          <router-view v-if="selectWithoutCharge()"></router-view>
        </div>
      </el-tab-pane>
      <el-tab-pane name="/donateTowards" label="赠菜原因">
        <div class="page-content">
          <router-view v-if="selectDonateTowards()"></router-view>
        </div>
      </el-tab-pane>
      <el-tab-pane name="/discountReason" label="折扣原因">
        <div class="page-content">
          <router-view v-if="selectDiscountReason()"></router-view>
        </div>
      </el-tab-pane>
      <el-tab-pane name="/tasteSetUp" label="口味设置">
        <div class="page-content">
          <router-view v-if="selectTasteSetUp()"></router-view>
        </div>
      </el-tab-pane>
      <el-tab-pane name="/egressionSold" label="外卖取消原因">
        <div class="page-content">
          <router-view v-if="selectEgressionSold()"></router-view>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
  //注意路径
  export default {
    data() {
      return {
        activityName: "/cinemaManage"
      };
    },
    watch: {
      $route(newValue, oldValue) {
        var path = this.$route.fullPath;
        if (path == "/assistMessage") {
          this.goHome();
          return;
        }
        if (path.startsWith("/reverseSettlement")) {
          this.activityName = "/reverseSettlement";
        } else if (path.startsWith("/retreatVegetable")) {
          this.activityName = "/retreatVegetable";
        }else if(path.startsWith("/withoutCharge")){
          this.activityName = "/withoutCharge";
        }else if(path.startsWith("/donateTowards")){
          this.activityName = "/donateTowards";
        }else if(path.startsWith("/discountReason")){
          this.activityName = "/discountReason";
        }else if(path.startsWith("/tasteSetUp")){
          this.activityName = "/tasteSetUp";
        }else if(path.startsWith("/egressionSold")){
          this.activityName = "/egressionSold";
        } else {
          this.activityName = this.$route.fullPath;
        }
      }
    },
    created() {
      window.this = this;
      console.log(this.$route);
      // this.activityName=this.$route.fullPath;
      this.goHome();
    },
    methods: {
      goBack() {
        this.router.go(-1);
      },
      goHome() {
        this.activityName = "/reverseSettlement";
        this.router.push({ path: "/reverseSettlement/dataTable" });
      },
      tabChange(active) {
        this.activityName = active.name;
        if (active.name == "/reverseSettlement") {
          this.router.push({ path: "/reverseSettlement/dataTable" });
        } else if (active.name == "/retreatVegetable") {
          this.router.push({ path: "/retreatVegetable/dataTable" });
        } else if(active.name == "/withoutCharge"){
          this.router.push({ path: "/withoutCharge/dataTable"});
        }else if(active.name == "/donateTowards"){
          this.router.push({ path: "/donateTowards/dataTable"});
        }else if(active.name == "/discountReason"){
          this.router.push({ path: "/discountReason/dataTable"});
        }else if(active.name == "/tasteSetUp"){
          this.router.push({ path: "/tasteSetUp/dataTable"});
        }else if(active.name == "/egressionSold"){
          this.router.push({ path: "/egressionSold/dataTable"});
        }else {
          this.router.push({ path: active.name});
        }
      },
      selectMaterials(){
        return this.activityName.startsWith("/reverseSettlement");
      },
      selectCategorys(){
        return this.activityName.startsWith("/retreatVegetable");
      },
      selectWithoutCharge(){
        return this.activityName.startsWith("/withoutCharge");
      },
      selectDonateTowards(){
        return this.activityName.startsWith("/donateTowards");
      },
      selectDiscountReason(){
        return this.activityName.startsWith("/discountReason");
      },
      selectTasteSetUp(){
        return this.activityName.startsWith("/tasteSetUp");
      },
      selectEgressionSold(){
        return this.activityName.startsWith("/egressionSold");
      }
    }
  };
</script>
<style scoped>
</style>
